/*******************************************************************************
* This header include classes used to open video files and camera devices.
* It uses ffmpeg libraries for video files and V4L2 and libdc1394 for camera
* devices.
* 
* 
* You can comment the headers you aren't intended to use. For example, if you don't
* intend to use a firewire camera, you can comment line '#include "cvvideo_ieee1394.h"'
*
*
* Licensed under GPL Version 3 license (/license.txt).
* Author: Eder A. Perez (eder.perez@ice.ufjf.br)
*******************************************************************************/

#include "cvvideo_vfile.h"     // Use a class to handle video files
#include "cvvideo_v4l2.h"      // Use a class to handle v4l2 devices
//#include "cvvideo_ieee1394.h"  // Use a class to handle firewire camera

/** Class for handle ieee1394-based cameras
*
#ifndef __CV_IEEE1394_CAMERA__
#define __CV_IEEE1394_CAMERA__

class CVVideoFirewire {
};
#endif


#ifndef __CV_VIDEO__
#define __CV_VIDEO__

#include "cvdatatypes.h"
#include <dc1394/dc1394.h>   // ieee1394 header

// Frame rate for IEEE1394 cameras
#define CV_IEEE1394_FRAMERATE_15  DC1394_FRAMERATE_15
#define CV_IEEE1394_FRAMERATE_30  DC1394_FRAMERATE_30
#define CV_IEEE1394_FRAMERATE_60  DC1394_FRAMERATE_60
#define CV_IEEE1394_FRAMERATE_120 DC1394_FRAMERATE_120
#define CV_IEEE1394_FRAMERATE_240 DC1394_FRAMERATE_240


// Numbers of dma buffers for IEEE1394 cameras
#define CV_DMA_BUFFERS 1



// IEEE1394 parameters structure
typedef struct __ieee1394_params {
  int camera_id; // This is the position in the array of cameras given by libdc1394,
                 // not the real camera id.
  int width;
  int height;
  dc1394framerate_t fps;
} CVieee1394params_t;



class CVVideo {

  /**********************
  *      ATTRIBUTES     *
  **********************

  public:
    // General attributes
    unsigned int width;
    unsigned int height;
    float        fps;
    unsigned int bpp;    
    unsigned int bitrate;  // In bits/second

    // For error handle
    int errorcode;

  private:
  
    // General private attributes
    int      input_type;     // Type of input (V4L2, IEEE1394 or video file)
    bool     input_opened;   // Open just one file/device at a time
    CVubyte  *buffer;        // Store a frame grabbed
    CVuint32 buffsize;       // Number of bytes allocated for buffer
    
    // IEEE1394 devices attributes
    dc1394_t            *dc1394;      // To initialize libdc1394
    dc1394camera_t      *camera;      // Camera device
    dc1394video_frame_t *frame_1394;  // For grabbing frames and info about the frame
    

  /**********************
  *       METHODS       *
  **********************
  
  public:
    // Constructors
    CVVideo();
    ~CVVideo();
    
    // General public methods
    bool openV4L2(const char* device, CVv4l2params_t params);
    bool openVideoFile(const char* path);
    bool openIEEE1394(CVieee1394params_t params);
    //bool openInput(const char* device, int input_type);
    //bool initCamera(int width, int height, int fps, int retrieve_fmt, int *device_fmt); // Prepare camera device for streaming
    bool getFrame(CVubyte* data); // Copies the current frame to data

  private:

    // IEEE1394 devices methods
    bool init_ieee1394_camera();
    bool get_frame_ieee1394(CVubyte* data);
    
    
  private:
    
    // General private methods
    bool (CVVideo::*get_frame_ptr)(CVubyte*); // Points to the correct get frame method
    int  getBpp(CVuint32 pxlfmt);             // Return bpp based on v4l2_pix_format
    
  
};

#endif
*/
